package com.pac.questionnaire.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.pac.questionnaire.bean.QuestionBean;
import com.pac.questionnaire.dao.QuestionDao;

/**
 * 问题Dao实现
 * 
 * @author lujun.chen
 * @version [版本号, 2015年2月14日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Repository(value = "questionDao")
public class QuestionDaoImpl implements QuestionDao {

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public String addQuestion(QuestionBean questionBean) {
		sqlSessionTemplate.insert("addQuestion", questionBean);
		return questionBean.getId();
	}

	@Override
	public boolean updateQuestion(QuestionBean questionBean) {
		int n = sqlSessionTemplate.update("updateQuestion", questionBean);
		return n > 0;
	}

	@Override
	public boolean delQuestion(QuestionBean questionBean) {
		int n = sqlSessionTemplate.delete("delQuestion", questionBean);
		return n > 0;
	}

	@Override
	public List<QuestionBean> queryQuestion(QuestionBean questionBean) {
		return sqlSessionTemplate.selectList("queryQuestion", questionBean);
	}

}
